const Mock = require('mockjs') // eslint-disable-line

// 设置1秒至4秒间响应
Mock.setup({ timeout: '1000-4000' });

export default {
    getTodoList() {
        // eslint-disable-next-line
        return new Promise((resolve, reject) => {
            // 返回分页数据
            let mockOptions = {
                status: 1,
                msg: 'success',
                'data|5-30': [{
                    id: '@increment()',
                    content: '@ctitle(1, 15)',
                    author: '管理员',
                    date: '@now()',
                    finished: '@boolean()'
                }]
            }
            let res = Mock.mock(mockOptions)
            res.data.forEach(item => {
                item.date = new Date(item.date).getTime()
            })

            resolve(res)
        })
    },
    getCartList() {
        // eslint-disable-next-line
        return new Promise((resolve, reject) => {
            // 返回分页数据
            let mockOptions = {
                status: 1,
                msg: 'success',
                'data|1-10': [{
                    id: '@increment()',
                    name: '@ctitle(1, 15)',
                    'price|50-9999': 50,
                    date: '@now()'
                }]
            }
            let res = Mock.mock(mockOptions)
            res.data.forEach(item => {
                item.date = new Date(item.date).getTime()
            })

            resolve(res)
        })
    },
    getUserList() {
        // eslint-disable-next-line
        return new Promise((resolve, reject) => {
            // 返回分页数据
            let mockOptions = {
                status: 1,
                msg: 'success',
                'data|1-10': [{
                    id: '@increment()',
                    "name": "@name",
                    "email": "@email",
                    "password|20": "",
                    'price|50-9999': 50,
                    date: '@now()'
                }]
            }
            let res = Mock.mock(mockOptions)
            res.data.forEach(item => {
                item.date = new Date(item.date).getTime()
            })

            resolve(res)
        })
    }
}